package tk.mybatis.springboot.mapper;

import org.apache.ibatis.annotations.Select;
import tk.mybatis.springboot.model.Course;
import tk.mybatis.springboot.model.CourseSession;
import tk.mybatis.springboot.model.StudentCourse;
import tk.mybatis.springboot.model.Students;

import java.util.HashMap;
import java.util.List;

public interface CourseMapper {

    @Select("select b.id,b.course_name as courseName, a.current_session_number as currentSessionNumber from student_course  a inner join course b on a.course_id = b.id where a.student_id = #{id}")
    List<Course> getMyCourse(String id);

    @Select("select id as id from course  where course_name = #{courseName}")
    String getCourseIdByName(String courseName);

    @Select("SELECT id, course_id as courseId , session_name as sessionName , session_number as sessionNumber, start_with as startWith, end_with as endWith from course_session where course_id = #{id}")
    List<CourseSession> getCourseSessionById(String id);

    @Select("select count(0) from student_course where student_id  =#{studentId} and class_id = #{courseId}")
    Integer getSignUpLog(String studentId, String courseId);

    Integer signUp(StudentCourse studentCourse);


}
